#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define debug(x) cerr<<#x<<':'<<x<<endl
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N=5e5+5;
const int fx[]={0,0,-1,1},fy[]={1,-1,0,0};
int n;
int x[N],y[N];
int l=1e9,r=0,u=0,d=1e9;
int dis[N];
int mp[4005][4005];
bool vis[N];
void bfs(int s){
    for(int i=1;i<=n;i++) vis[i]=0;
    queue<pair<int,int> > q;
    q.push({x[s],y[s]});
    dis[s]=0;
    vis[s]=1;
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop();
        for(int i=0;i<4;i++){
            int nx=x+fx[i],ny=y+fy[i];
            int tmp=mp[nx][ny];
            if(!tmp||vis[tmp]) continue;
            vis[tmp]=1;
            dis[tmp]=dis[mp[x][y]]+1;
            q.push({nx,ny});
        }
    }
}
signed main(){
    freopen("game.in","r",stdin);
    freopen("game.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        l=min(l,x[i]);
        r=max(r,x[i]);
        d=min(d,y[i]);
        u=max(u,y[i]);
    }
    if(n<=4000){
        for(int i=1;i<=n;i++) x[i]-=l,y[i]-=d;
        for(int i=1;i<=n;i++) mp[x[i]][y[i]]=i;
        int ans=0;
        for(int s=1;s<=n;s++){
            bfs(s);
            for(int i=s+1;i<=n;i++) ans+=dis[i];
        }
        cout<<ans<<endl;
        return 0;
    }
    int ans=0;
    for(int i=l;i<=r;i++){
        int a=i*(i-l+1)-(l+i)*(i-l+1)/2;
        int b=(i+r)*(r-i+1)/2-(r-i+1)*i;
        ans+=(u-d+1)*(u-d+1)*(a+b);
    }
    for(int i=d;i<=u;i++){
        int a=i*(i-d+1)-(d+i)*(i-d+1)/2;
        int b=(i+u)*(u-i+1)/2-(u-i+1)*i;
        ans+=(r-l+1)*(r-l+1)*(a+b);
    }
    cout<<ans/2<<endl;
    return 0;
}